<template>
    <div>
    <h1>欢迎{{$store.state.username}} <button @click="exit">退出登录</button></h1>
</div>
</template>

<script>
export default {
    data() {
        return {};
    },
    mounted() {},
    methods: {
    exit(){
        this.$store.commit("exit")
        this.$router.push("/login")
    }
},
beforeRouteEnter (to, from, next) {
    next((vm)=>{
        if(vm.$store.state.username){
            next()
        }else{
            next("/login")
        }
    })
}
};
</script>

<style lang='scss'>

</style>
